package com.leiyuee.mybatis.util;

import java.util.HashMap;

/**
 * Created by Administrator on 2018/5/3.
 */
public class Result extends HashMap<String, Object> {

    private static final long serialVersionUID = 1L;

    public static final int errorCode = 500;

    public Result() {
        put("code", 200);
    }

    public static Result error() {
        return error(errorCode, "","未知异常，请联系管理员");
    }

    public static Result error(Object data,Object msg) {
        return error(errorCode, data, msg);
    }

    public static Result error(Object msg) {
        return error(errorCode,"", msg);
    }


    public static Result error(int code,Object data, Object msg) {
        Result r = new Result();
        r.put("code", code);
        r.put("data",data);
        r.put("msg", msg);
        return r;
    }

    public static Result ok() {
        return new Result();
    }

    public static Result ok(Object data) {
        Result r = new Result();
        r.put("msg", "");
        r.put("data",data);
        return r;
    }

    public static Result ok(Object data,Object msg) {
        Result r = new Result();
        r.put("msg", msg);
        r.put("data",data);
        return r;
    }


}
